package com.youxin.dataSet

import org.apache.flink.api.scala._

class Iiterator {}
object Iiterator{
  def main(args: Array[String]): Unit = {
    //val env = ExecutionEnvironment.getExecutionEnvironment
    val env = ExecutionEnvironment.createLocalEnvironment()
    val initial = env.fromElements(0,1)
    val count = initial.iterate(100) { iterationInput: DataSet[Int] =>
      val result = iterationInput.map {
        i =>
          val x = Math.random()
          val y = Math.random()
          i + (if (x * x + y * y < 1) 1 else 0)
      }
      result
    }
    val result = count.map(_ / 10000 * 4)

    result.print()

    //env.execute("pi Example")

  }
}
